package cn.signalpha.modules.base.controller.api;

import cn.signalpha.core.boot.ctrl.BaseController;
import cn.signalpha.common.constant.AppConstant;
import cn.signalpha.core.tool.api.R;
import cn.signalpha.modules.base.entity.Banner;
import cn.signalpha.modules.base.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 控制器
 *
 * @author signalpha
 */
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_BASE_NAME + "/wap/banner")
@Api(value = "banner", tags = "banner")
public class ApiBannerController extends BaseController {

	private final BannerService bannerService;

	@GetMapping("/list")
	@ApiOperation(value = "列表", notes = "")
	public R<List<Banner>> list(@RequestParam Integer type) {
		return R.data(bannerService.listCache(type));
	}

	@GetMapping("/info")
	@ApiOperation(value = "详情", notes = "传入id")
	public R<Banner> info(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
		return R.data(bannerService.getByCache(id));
	}

}
